package com.bwie.advertisement.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bwie.common.log.annotation.Log;
import com.bwie.common.log.enums.BusinessType;
import com.bwie.common.security.annotation.RequiresPermissions;
import com.bwie.advertisement.domain.PmsAdvertisement;
import com.bwie.advertisement.service.IPmsAdvertisementService;
import com.bwie.common.core.web.controller.BaseController;
import com.bwie.common.core.web.domain.AjaxResult;
import com.bwie.common.core.utils.poi.ExcelUtil;
import com.bwie.common.core.web.page.TableDataInfo;

/**
 * 上海云计算-新零售-广告管理
 * 李汉城
 * @author ruoyi
 * @date 2025-02-14
 */
@RestController
@RequestMapping("/advertisement")
public class PmsAdvertisementController extends BaseController
{
    @Autowired
    private IPmsAdvertisementService pmsAdvertisementService;

    /**
     * 查询广告列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PmsAdvertisement pmsAdvertisement)
    {
        startPage();
        List<PmsAdvertisement> list = pmsAdvertisementService.selectPmsAdvertisementList(pmsAdvertisement);
        return getDataTable(list);
    }


    /**
     * 获取广告详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pmsAdvertisementService.selectPmsAdvertisementById(id));
    }

    /**
     * 新增广告
     */
    @PostMapping
    public AjaxResult add(@RequestBody PmsAdvertisement pmsAdvertisement)
    {
        return toAjax(pmsAdvertisementService.insertPmsAdvertisement(pmsAdvertisement));
    }

    /**
     * 修改广告
     */
    @PutMapping
    public AjaxResult edit(@RequestBody PmsAdvertisement pmsAdvertisement)
    {
        return toAjax(pmsAdvertisementService.updatePmsAdvertisement(pmsAdvertisement));
    }

    /**
     * 删除广告
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pmsAdvertisementService.deletePmsAdvertisementByIds(ids));
    }

}
